package com.lihaogn.validator;

public class LeapYearValidator {

    private int year;

    public LeapYearValidator(int year) {
        this.year = year;
    }

    public boolean isLeapYear() {
        if (((this.year % 4 == 0) & (year % 100 != 0)) | (year % 400 == 0)) {
            // 能被4整除但不能被100整除的年份，或者能被400整除的年份
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        int year = 2008;
        LeapYearValidator yearValidator = new LeapYearValidator(year);
        boolean isLeapYear = yearValidator.isLeapYear();
        if (isLeapYear) {
            System.out.println(year + "是闰年");
        } else {
            System.out.println(year + "不是闰年");
        }
    }
}
